package cn.buk.tms.dto;

import cn.buk.qms.BillUtil;
import cn.buk.tms.entity.bill.BillVasOrder;
import cn.buk.tms.entity.misc.Customer;
import cn.buk.tms.entity.misc.FlightInfo;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * 输出报表时的增值服务内容
 */
public class SettlementReportVasDto {

	public static SettlementReportVasDto createByBillVas(BillVasOrder o) {
		SettlementReportVasDto dto = new SettlementReportVasDto();

		BeanUtils.copyProperties(o, dto);

		BillUtil.processRouteDetail(o.getRouteDetail(), o.getFlights());

		dto.setDetails(new ArrayList<>());
		for(FlightInfo fltInfo: o.getFlights()) {
			ReportTicketDetailDto detailDto = ReportTicketDetailDto.createByFlightInfo(fltInfo);

			dto.getDetails().add(detailDto);
		}

		return dto;
	}

	private int id;

	private int enterpriseId;

	private String billNum;


	/**
	 * 订单号
	 */
	private String orderNo;

	/**
	 * 相关联的机票订单号
	 */
	private String flightOrderNo;

	/**
	 * 服务单的生成日期（用于结算单报表）
	 */
	@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
	private Date orderDate;


	private int productType; //商品类型： 保险，门票等
	/**
	 * 增值服务产品的代码：TieInProduct.productCode
	 */
	private String productCode;

	private String productName;

	/**
	 * 客户类型
	 * 0 - 代表散客
	 * 1 - 代表企业客户
	 */
	private int customerType;

	/**
	 * 客户在系统中的id: 在t102中对应的ID
	 */
	private Customer customer;

	private Integer customerId;

	/**
	 * 成本中心
	 */
	private String costCenter;

	/**
	 * 标价
	 */
	private double price;

	/**
	 * 折扣金额
	 */
	private double discount;

	/**
	 * 成本
	 */
	private double cost;

	/**
	 * 数量
	 */
	private int count;

	/**
	 * 利润 = count * (price - discount- cost)
	 */
	private double profit;

	private Double total;

	/**
	 * 该账单客户的付款方式
	 * 1-现金；
	 * 2-信用卡；
	 * 4-支票；
	 * 8-记账
	 */
	private int payType;

	/**
	 * 付款状态(只有付款类型非记账方式时才有用）
	 * 0 or null 未支付
	 * 1 已支付
	 */
	private Integer payStatus;

	/**
	 * 是否已付款(财务销账）
	 */
	private String bePaid;

	/**
	 * 服务订单中对应的人名（如果有），多个人名用分号（；）隔开
	 */
	private String passengerName;

	private List<String> passengers = new ArrayList<>();

	/**
	 * 服务订单中对应的航班信息（如果有），方便做报表的时候显示
	 */
	private String routeDetail;


	private String remark;

	private Date createTime;

	private Date lastUpdate;

	/**
	 * 用于保险订单的金额合并到机票票号中
	 * 是否需要移除
	 * 1 - 需要
	 */
	private int removed;

	private List<ReportTicketDetailDto> details;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getEnterpriseId() {
		return enterpriseId;
	}

	public void setEnterpriseId(int enterpriseId) {
		this.enterpriseId = enterpriseId;
	}

	public String getBillNum() {
		return billNum;
	}

	public void setBillNum(String billNum) {
		this.billNum = billNum;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public Date getOrderDate() {
		return orderDate;
	}

	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}

	public int getProductType() {
		return productType;
	}

	public void setProductType(int productType) {
		this.productType = productType;
	}

	public String getProductCode() {
		return productCode;
	}

	public void setProductCode(String productCode) {
		this.productCode = productCode;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public int getCustomerType() {
		return customerType;
	}

	public void setCustomerType(int customerType) {
		this.customerType = customerType;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Integer getCustomerId() {
		return customerId;
	}

	public void setCustomerId(Integer customerId) {
		this.customerId = customerId;
	}

	public String getCostCenter() {
		return costCenter;
	}

	public void setCostCenter(String costCenter) {
		this.costCenter = costCenter;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public double getDiscount() {
		return discount;
	}

	public void setDiscount(double discount) {
		this.discount = discount;
	}

	public double getCost() {
		return cost;
	}

	public void setCost(double cost) {
		this.cost = cost;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public double getProfit() {
		return profit;
	}

	public void setProfit(double profit) {
		this.profit = profit;
	}

	public Double getTotal() {
		return total;
	}

	public void setTotal(Double total) {
		this.total = total;
	}

	public int getPayType() {
		return payType;
	}

	public void setPayType(int payType) {
		this.payType = payType;
	}

	public Integer getPayStatus() {
		return payStatus;
	}

	public void setPayStatus(Integer payStatus) {
		this.payStatus = payStatus;
	}

	public String getBePaid() {
		return bePaid;
	}

	public void setBePaid(String bePaid) {
		this.bePaid = bePaid;
	}

	public String getPassengerName() {
		return passengerName;
	}

	public void setPassengerName(String passengerName) {
		this.passengerName = passengerName;
	}

	public String getRouteDetail() {
		return routeDetail;
	}

	public void setRouteDetail(String routeDetail) {
		this.routeDetail = routeDetail;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getLastUpdate() {
		return lastUpdate;
	}

	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	public List<ReportTicketDetailDto> getDetails() {
		return details;
	}

	public void setDetails(List<ReportTicketDetailDto> details) {
		this.details = details;
	}

	public String getFlightOrderNo() {
		return flightOrderNo;
	}

	public void setFlightOrderNo(String flightOrderNo) {
		this.flightOrderNo = flightOrderNo;
	}

	public int getRemoved() {
		return removed;
	}

	public void setRemoved(int removed) {
		this.removed = removed;
	}

	public List<String> getPassengers() {
		return passengers;
	}

	public void setPassengers(List<String> passengers) {
		this.passengers = passengers;
	}
}
